<?php
include_once('../function/AlarmReveal.html');
header('content-type: text/html; charset=utf-8');
session_start();
include('../config.php'); 

if(!isset($_SESSION['ID']))
{
	header("Location:../login/index.php");
}
else
{
	if((!isset($_POST["userid"]))||($_POST["userid"]==""))
	{
		echo '<script> AlarmReveal("../user/index.php", "Failed!!!Please input the username and password.", 220); </script>';
	}
	else
	{
		
		$userid = ($_POST["userid"]);
		//$pwd = ($_POST["userpwdefault"]);
		$pwd = 111;
		LinkDataBase();
		
		$sql = "INSERT INTO `sqlserver`.`member` (`id`, `password`, `firstlogin`) VALUES ('".$userid."', '".$pwd."', '0')";
		if(mysql_query($sql))
		{
			echo '<script> AlarmReveal("../detail/index.php", "User has been successfully added.", 220); </script>';
		}
		else
		{
			echo '<script> AlarmReveal("../user/index.php", "User existed", 220); </script>';
		}		
	}
}

?>
